
% data=load_bin('E:\RawData\GK_111209_c\ImagingData\2012-01-07\exp17014_ch-525.bin');
% aux_data=load_lvd('E:\RawData\GK_111204_a\Data\2012-01-11\GK_111204_a0011.lvd');
% [vdata,vaux]=load_vid_data('E:\RawData\GK_111204_a\Data\2012-01-11\GK_111204_a0011.vid');
% load('N:\AnalyzedData\georg\GK_111209_c\2012-01-07\GK_111209_c-Adata-17014.mat')
% data=shift_data(data,dx,dy);


vftimes=vaux(2,:)-vaux(2,1)+750;
frame_times=get_frame_times(aux_data(3,:));


vidMdata=zeros(size(data,1),size(data,2),size(vdata,3)-2*window_length,'uint8');

window_length=20;

for ind=window_length+1:size(vdata,3)-window_length
    [~,pos]=min(abs(vftimes(ind)-frame_times));
    vidMdata(:,:,ind-window_length)=uint8(mean(data(:,:,pos-window_length:pos+window_length),3));
end

vdata2=permute(vdata([1:2:end],[1:2:end],window_length+1:size(vdata,3)-window_length),[2 1 3]);


aaa=zeros(size(vidMdata,1),size(vidMdata,2)+size(vdata2,2),size(vidMdata,3),'uint8');
aaa(:,1:size(vidMdata,2),:)=vidMdata-40;
aaa(1:size(vdata2,1),size(vidMdata,2)+1:end,:)=vdata2;

